<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<div class="top-sysInfo">dangda</div>
<div class="top-userinfo">
	<table>
		<tr>
			<td style="border: none;">欢迎您 ${sessionScope._CURRENT_USER.view_name}</td>

			<!--<td>当前角色： ${sessionInfo.user.roleName}</td>
		 	<td>未读消息-<span id="spanMsgCount">89</span>
			</td> -->
			<td><a href="javascript:void(0)" onclick="openDialogPassword();">修改密码</a></td>
			<td><a id="aLogout" href="dologinout" onclick="doLogout();">安全退出</a></td>
		</tr>
	</table>
</div>
<div id="updatePasswordDialg" class="easyui-dialog" title="修改密码"
	style="width:355px;height:185px;"
	data-options="iconCls:'icon-save',closed:true,modal:true,	   
				buttons: [{
					text:'确定', 
					iconCls:'icon-ok',
					handler:doChange
				},{
					text:'取消',
					iconCls:'icon-cancel',
					handler:closeDialogPassword
				}]
			">
	<div id="editForm" class="form-box">
		<div class="form-group notnull">
			<div class="form-label w40">原始密码</div>
			<div class="form-editor w60">
				<input type="password" id="oldPassword" name="oldPassword"
					class="w-auto text" />
			</div>
		</div>
		<div class="form-group notnull">
			<div class="form-label w40">新密码</div>
			<div class="form-editor w60">
				<input type="password" id="newPassword" name="newPassword"
					class="w-auto text" />
			</div>
		</div>
		<div class="form-group notnull">
			<div class="form-label w40">确认密码</div>
			<div class="form-editor w60">
				<input type="password" id="checkPassword" name="checkPassword"
					class="w-auto text" />
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	function openDialogPassword() {
		$("#updatePasswordDialg").dialog("open");
	}
	function closeDialogPassword() {
		$("#updatePasswordDialg").dialog("close");
	}
	function doChange() {
		/**新增保存或修改保存 验证数据**/
		if (!validateForm()) {
			return false;
		}
		var oldPassword = $("#oldPassword").val();
		var newPassword = $("#newPassword").val();
		var checkPassword = $("#checkPassword").val();
		if (newPassword != checkPassword) {
			alert("新密码和确认密码不一致。");
			return;
		}
		$.ajax({
			url : "${basePath}UserController/changePassword.do",
			data : {
				"employeeID" : "${loginUser.employeeID}",
				"oldPassword" : oldPassword,
				"newPassword" : newPassword
			},
			type : "POST",
			dataType : "JSON",
			cache : false,
			async : false,
			beforeSend : function(xhr) {
				$.messager.progress({
					title : "提示",
					text : "数据正在处理中，请稍后...."
				});
			},
			complete : function(xhr, ts) {
				$.messager.progress("close");
			},
			success : function(result, textStatus, xhr) {
				if (result.success) {
					alert("密码已修改。");
				} else {
					alert(result.message);
				}
			},
			error : function(xhr, errorMsg, errorObj) {
				alert(errorMsg + " - " + errorObj);
			}
		});

	}
</script>